<template>
<view class="wrap">
		<view class="top">
			<view class="title">沂蒙乡村振兴投稿系统V1.0</view>
		</view>
       <view class="content">
			<!-- 两个标题 -->
			<view>
				<view class="zuo">
				<u-tabs  :list="tabList" :is-scroll="false" ></u-tabs>
				</view>
				<view class="you" >
				<navigator url="../login1/login1"> <u-tabs  :list="tabList2" :is-scroll="false" :bar-style="barStyle" > </u-tabs></navigator>
				</view>
				
				<!-- 账号密码登陆 -->
				<view>
				<view class="username">
					<u-input  v-model="username" type="text" height="70" :border="true" placeholder="用户名" />
				</view>
				<view class="password">
					<u-input class="password" v-model="password" type="password"  height="70"   :border="true" placeholder="密码" />
				</view>
				</view>
				<button @tap="login" :style="[inputStyle]" class="getCaptcha">登录</button>
				<!-- <view class="Forget">
					<navigator url="../verification/verification">忘记密码</navigator> 
				</view> -->
			</view>	
		</view>
		<view class="bottom">Copyright 2021高职院校沂蒙乡村振兴投稿系统</view>
	</view>
</template>

<script>
	import api from '../../util/api.js'
	import request from '../../util/request.js'
	import 'bootstrap/dist/css/bootstrap.min.css'
	
	export default {
		data() {
			return {
				barStyle:{backgroundColor:'#ffffff'},
				token:'',
				code:'',
				tabList: [{
						name: '账号密码登陆',
					},
				],
				tabList2: [{
						name: '手机号登陆',
					},
				],
				current: 0,
				username: 'linker',
				password: 'linker@123',
				author:'linker',
				userInfo:null
			}
		},
		computed: {
			inputStyle() {
				let style = {
					
				};
				if (this.password) {
					style.color = "#fff";
					style.backgroundColor = '#2f7df9';
				}
				return style;
			}
			},
			onLoad() {
			let userInfo=uni.getStorageSync("userInfo");
				// if(userInfo){
				// 	uni.navigateTo({
				// 		url:'/pages/new/new'
				// 	})
				// }
			},
		methods: {
			login(){
				if(this.username==""||this.password==""){
					uni.showToast({
						icon:'none',
						title:'用户名或者密码不能为空'
					})
				}else{		
					request.postf(api.login,{
						username:this.username,
						password:this.password
					}).then(response=>{
						if(response.data.code === 0){
							console.log("登陆成功", response.data);
							uni.setStorageSync('token',response.data.msg);
							uni.setStorageSync('username',this.username);
							uni.setStorageSync('author',this.author);
							uni.switchTab({
								url:'/pages/new/new'
							})
						} else {
							
							uni.showToast({
								icon:'none',
								title:'用户名或密码错误',
							})
						}
					}).catch(ex=>{
						uni.showToast({
							icon:'none',
							title:'请求失败，请稍后再试'
						})
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.top {
		background-size: 100%;
		height: 320rpx;
		width: 770px;
		text-align: center;
		padding-top: 35rpx;
	}
	.logo{
		text-align: center;
		width: 600rpx;
		height: 200rpx;
	}
	.title {
		font-size: 50rpx;
		margin: 0px auto;
		color: #ffffff;
		font-weight: bold;
	}
	.zuo{
		margin-left: 50px;
		margin-bottom: 40rpx;
		width: 310px;
		display: inline-block;
	}
	.you{
		margin-bottom: 40rpx;
		display: inline-block;
		width: 150px;
		}
		
	.username{
		margin-left: 10px;
		margin-bottom: 10rpx;
		width: 600px;
	}
	.password{
		margin-left: 10px;
		margin-bottom: 50rpx;
		width: 600px;
	}
	.wrap {
		font-size: 28rpx;
		background: url() no-repeat;
		background-size: 310%;
		height: 1335px;
		}
		.content {
			border-radius: 20px;
			box-shadow: 1px 1px 2px 2px rgba(255, 0, 0, 0.1);
			width: 650rpx;
			margin: 80rpx auto;
			padding: 50px 10rpx;
			padding-top: 30rpx;
			margin-top: -50rpx;
			margin-left: 50px;
			background-color: #FFFFFF;

			.getCaptcha {
				background-color: #F1F1F1;
				color: $u-tips-color;
				font-size: 29rpx;
				padding: 12rpx 0;
				margin-top: 20px;

				&::after {
					border: none;
				}
			}
			// .Forget{
			// 	color: #007AFF;
			// 	margin-top: 20px;
			// 	margin-left: 500px;
			// 	font-size: 25px;
			// }
			

		}

	
	.bottom{
		position: fixed;
		bottom: 0rpx;
		text-align: center;
		width: 100%;
		margin: 0 auto;
	}
</style>
